package com.zer0.tga.art;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.zer0.tga.Game;

public class ArtArchive {
	
	// ADD EVERYTHING!
	
	//Each art here consists of a Bitmap matrix as Bitmap[frame][direction/other/etc]
/*	
 	public static Bitmap[][] Teemo_Shroom = crop("/floortiles.png", 96, 96);
	
	
	public static Bitmap[][] Garen = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Katarina = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Rammus = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Shaco = crop("/floortiles.png", 96, 96);
	
	public static Bitmap[][] Garen_DJustice = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Shaco_Box = crop("/floortiles.png", 96, 96);
	

	public static Bitmap[][] MeleeMinion = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] CasterMinion = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] SmallGolem = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Golem = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] SmallWolf = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Wolf = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Turret = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Whelp = crop("/floortiles.png", 96, 96);	
	public static Bitmap[][] SmallWraith = crop("/floortiles.png", 96, 96);
	public static Bitmap[][] Wraith = crop("/floortiles.png", 96, 96);*/

	public static Bitmap[][] Teemo = crop("res/link.png", 64, 64);
	
	
	public static Bitmap[][] grassTile = crop("res/grass.png",64,64);
	public static Bitmap[][] wallTile = crop("res/v2.png",64,64);
	public static Bitmap[][] rockTile = crop("res/tileset.png",64,64);
	public static Bitmap[][] breakableRockTile = crop("res/tileset.png",64,64);
	public static Bitmap[][] brokenRockTile = crop("res/tileset.png",64,64);
	public static Bitmap[][] holeTile = crop("res/tileset.png",64,64);
	
	public static Bitmap[][] bullet = crop("res/bullet.png",32,32);
	public static Bitmap[][] bullet2 = crop("res/bullet2.png",32,32);
	
	public static Bitmap[][] startMenu = crop("res/startMenu.png",832,666);
	public static Bitmap[][] startMenuButtons = crop("res/startMenuButtons.png",100,50);
	public static Bitmap[][] introUi = crop("res/introUi.png",832,666);
	
	public static Bitmap[][] badguy = crop("res/badguy.png",64,64);
	public static Bitmap[][] badguy2 = crop("res/badguy.png",64,64);
	public static Bitmap[][] badguy3 = crop("res/badguy.png",64,64);
	public static Bitmap[][] badguy4 = crop("res/badguy.png",64,64);
	
	public static Bitmap[][] boomerangblade = crop("res/boomerangblade.png",64,64);
	
	
	public static Bitmap[][] minimap = crop("res/minimap.png",11,9);
	public static Bitmap[][] minimap2 = crop("res/minimap2.png",22,18);
	public static Bitmap[][] minimap3 = crop("res/minimap3.png",22,18);
	
	public static Bitmap[][] heart = crop("res/heart.png",40,40);
	public static Bitmap[][] mushroom = crop("res/mushroom.png",40,40);
	public static Bitmap[][] gold = crop("res/gold.png",40,40);
	
	public static Bitmap[][] bossSign = crop("res/bossSign.png",128,128);
	public static Bitmap[][] shopSign = crop("res/shopSign.png",128,128);
	
	public static Bitmap[][] fader = crop("res/fader.png",832,576);
	public static Bitmap[][] welcome = crop("res/welcome.png",512,256);
	public static Bitmap[][] gameover = crop("res/gameover.png",512,256);
	
	public static Bitmap[][] shopMenu = crop("res/shopMenu.png",832,666);
	public static Bitmap[][] items = crop("res/items.png",50,50);
	public static Bitmap[][] selection = crop("res/selection.png",60,60);
	public static Bitmap[][] selection2 = crop("res/selection2.png",74,74);
	public static Bitmap[][] selection3 = crop("res/selection2.png",70,70);
	
	public static Bitmap[][] achvMenu = crop("res/achvMenu.png",832,666);
	public static Bitmap[][] shopMenu2 = crop("res/shopMenu2.png",752,600);
	
	public static Bitmap[][] lolItems = crop("res/lolitems.png",64,64);
	public static Bitmap[][] lolChamps = crop("res/lolchamps.png",60,60);
	

	
	
   /* private static Bitmap[][] crop(String string, int w, int h) {
        return crop(string, w, h, 0, 0);
    }
    */
    private static Bitmap[][] crop(String string, int w, int h)
    {
    try {
        BufferedImage b;
        if(Game.class.getResource("Game.class").toString().startsWith("jar"))
		   	b = ImageIO.read(Game.class.getClass().getResourceAsStream("/"+string));
       else
           	b = ImageIO.read(new File(string));
        
        int xTiles = b.getWidth() / w;
        int yTiles = b.getHeight() / h;

        Bitmap[][] result = new Bitmap[xTiles][yTiles];

        for (int x = 0; x < xTiles; x++) {
            for (int y = 0; y < yTiles; y++) {
                result[x][y] = new Bitmap(w, h);
                b.getRGB(x*w, y*h, w, h, result[x][y].pixel, 0, w);
            }
        }

        return result;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
}
